<?PHP
    require_once('ConnectionMysql.php');
    require_once('TipoUsuario.php');

    class TipoUsuarioDAO
    {
        private $connection = NULL;


        /*************************************************************************
        * Name: __construct
        * Description: Construtor da Classe. Inicializar os Atributos.
        * Parameters: 
        * Returns: Nenhum
        * Author: 
        * Last Modified: 00/00/00 - Autor da Modificação
        *************************************************************************/
        public function __construct()
        {
                $this->connection = new ConnectionMysql(); // Cria a Conexão.
        }


        /*************************************************************************
        * Name: 
        * Description: 
        * Parameters: 
        * Returns: 
        * Author: Felipe O. Simões
        * Last Modified: 07/04/2012 - Felipe O. Simões
        *************************************************************************/
        public function insert(TipoUsuario $obj)
        {
            $sql = "INSERT INTO tipousuario (tipo, isAtivo) VALUES ('". $obj->getTipo() ."', '". $obj->getIsAtivo() ."')";

            return $this->connection->queryConnect($sql);
        }


        /*************************************************************************
        * Name: 
        * Description: 
        * Parameters: 
        * Returns: 
        * Author: Felipe O. Simões
        * Last Modified: 07/04/2012 - Felipe O. Simões
        *************************************************************************/
        public function deletePorId($id)
        {
            $sql = "UPDATE tipousuario SET isAtivo='N' WHERE idTipoUsuario=". $id;

            return $this->connection->queryConnect($sql);
        }


        /*************************************************************************
        * Name: 
        * Description: 
        * Parameters: 
        * Returns: 
        * Author: Felipe O. Simões
        * Last Modified: 07/04/2012 - Felipe O. Simões
        *************************************************************************/
        public function deletePorObj(TipoUsuario $obj)
        {
            $sql = "UPDATE tipousuario SET isAtivo='N' WHERE idTipoUsuario=". $obj->getIdTipoUsuario();

            return $this->connection->queryConnect($sql);
        }


        /*************************************************************************
        * Name: 
        * Description: 
        * Parameters: 
        * Returns: 
        * Author: Felipe O. Simões
        * Last Modified: 07/04/2012 - Felipe O. Simões
        *************************************************************************/
        public function update(TipoUsuario $obj)
        {
            $sql = "UPDATE tipousuario SET tipo='". $obj->getTipo() ."', isAtivo='". $obj->getIsAtivo() ."' WHERE idTipoUsuario=". $obj->getIdTipoUsuario();
            
            return $this->connection->queryConnect($sql);
        }


        /*************************************************************************
        * Name: 
        * Description: 
        * Parameters: 
        * Returns: 
        * Author: Felipe O. Simões
        * Last Modified: 07/04/2012 - Felipe O. Simões
        *************************************************************************/
        public function select()
        {

        }
    }
?>